Skip to content

Add log level settings for auto skills#883

Merged
wangxingjun778 merged 1 commit intomodelscope:mainfrom
wangxingjun778:fix/logger
Mar 17, 2026
Merged

Add log level settings for auto skills#883
wangxingjun778 merged 1 commit intomodelscope:mainfrom
wangxingjun778:fix/logger

Conversation

@wangxingjun778
Copy link
Collaborator

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces enhanced logging flexibility by allowing the log level to be controlled via an environment variable. This change streamlines the process of adjusting logging verbosity, which is crucial for debugging and monitoring, by centralizing the configuration and enabling runtime modifications without requiring application restarts.

Highlights

  • Dynamic Log Level Configuration: Implemented the ability to configure the logging level for auto skills dynamically using the LOG_LEVEL environment variable. This allows for easier debugging and operational adjustments without code changes.
  • Logger Refresh Functionality: Added a new utility function, refresh_log_level, which allows for updating a logger's level and its handlers' levels at runtime based on the current LOG_LEVEL environment variable.
  • Consistent Log Level Application: Ensured that all relevant loggers and their handlers, including file handlers, correctly adopt the log level specified by the LOG_LEVEL environment variable upon initialization and dynamic updates.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • ms_agent/skill/auto_skills.py
    • Imported the os module to access environment variables.
    • Added logic to read the LOG_LEVEL environment variable and apply it to the logger and its handlers during configuration.
    • Updated the file handler's level to explicitly use the dynamically determined log_level.
  • ms_agent/utils/logger.py
    • Modified the get_logger function to dynamically update the log level of existing loggers and their handlers based on the LOG_LEVEL environment variable.
    • Introduced a new function refresh_log_level to allow for runtime updates of a logger's level from the environment variable.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces functionality to configure the logger level via the LOG_LEVEL environment variable. The changes are implemented in auto_skills.py and utils/logger.py, with a new helper function refresh_log_level to centralize some of this logic. My review focuses on further reducing code duplication by leveraging this new helper function more effectively and identifying another opportunity for consolidation within utils/logger.py to improve maintainability.

Comment on lines +44 to +50
log_level_str = os.getenv('LOG_LEVEL', 'INFO').upper()
log_level = getattr(logging, log_level_str, logging.INFO)

# Update logger level to respect current LOG_LEVEL env var
logger.setLevel(log_level)
for handler in logger.handlers:
handler.setLevel(log_level)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To avoid code duplication, you can use the new refresh_log_level function that you've added in ms_agent/utils/logger.py. This will make the code more maintainable.

You'll need to import it at the top of the file:

from ms_agent.utils.logger import get_logger, refresh_log_level
Suggested change
log_level_str = os.getenv('LOG_LEVEL', 'INFO').upper()
log_level = getattr(logging, log_level_str, logging.INFO)
# Update logger level to respect current LOG_LEVEL env var
logger.setLevel(log_level)
for handler in logger.handlers:
handler.setLevel(log_level)
log_level = refresh_log_level(logger)

Comment on lines +151 to +153
target_logger.setLevel(log_level_int)
for handler in target_logger.handlers:
handler.setLevel(log_level_int)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This logic to set the level on the logger and its handlers is duplicated in the get_logger function (lines 57-59). To improve maintainability and avoid duplication, consider extracting this block into a private helper function, e.g., _set_level(logger, level), and call it from both get_logger and refresh_log_level.

@wangxingjun778 wangxingjun778 merged commit 4420df4 into modelscope:main Mar 17, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants